﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NCP.Recruiting.ApplicationServices.Interfaces;
using NCP.Recruiting.ApplicationServices.ViewModels;

namespace NCP.Recruiting.WebApp.Controllers {

     [Authorize]
    public class AuthorizedController : Controller {
        private readonly ICompanyAppService _companyAppService;
        private User currentUser;

        public AuthorizedController(ICompanyAppService companyAppService) {
            this._companyAppService = companyAppService;
        }

        protected Guid CurrentUserId {
            get { return this.User.RecruitingIdentity().UserId; }
        }

        public User CurrentUser {
            get {
                return this.currentUser ??
                    (this.currentUser = this._companyAppService.GetUserFromIdentity(this.User.RecruitingIdentity()));
            }
        }


    }
}
